﻿using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;

namespace MotivLogger
{
    public class ForEachModuleLog : ILogMethod
    {
        private ISetting LoggerSettings;
        private string path;
        public ForEachModuleLog()
        {
            LoggerSettings = Settings.getSetting("logger");
            string path = this.LoggerSettings.GetData("logpath");
            if (path == null)
                path = "C:\\logs2";
           
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
        }
        public void Log(MotivLogger.LogLevels Level, string Message, string Actor)
        {
            string path = this.LoggerSettings.GetData("logpath");
            string message = LoggerBase.BuildLogRecord(Level, Message, Actor);
            string log = Actor.ToLower() + ".log";
            StreamWriter w = new StreamWriter(Path.Combine(path, log), true);
            w.WriteLine(message);
            w.Close();
        }

        public void Stop() { ;}
    }
}
